﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Speech.Synthesis;
using System.Text;

namespace Gw2Overlay
{
    public class TtsService
    {
        static readonly TtsService instance = new TtsService();
        static TtsService()
        {
        }
        TtsService()
        {
            synth = new SpeechSynthesizer();
            synth.Rate = 1;
        }
        ~TtsService()
        {
            synth.Dispose();
        }
        public static TtsService Instance
        {
            get
            {
                return instance;
            }
        }

        private SpeechSynthesizer synth;

        public void Speak(string s)
        {
            PromptBuilder pb = new PromptBuilder();
            pb.AppendText(s);
            synth.SpeakAsync(pb);
        }

        public ReadOnlyCollection<InstalledVoice> GetInstalledVoices()
        {
            ReadOnlyCollection<InstalledVoice> voices = synth.GetInstalledVoices();
            return voices;
        }

        public void SelectVoice(string name)
        {
            synth.SelectVoice(name);
        }
    }
}
